package com.ynsj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynsj.mapper.UserAddressMapper;
import com.ynsj.domain.UserAddress;
import com.ynsj.service.UserAddressService;
import org.springframework.util.StringUtils;

@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements UserAddressService{

    /**
     * 分页查询会员钱包地址信息
     *
     * @param page
     * @param userId
     * @return
     */
    @Override
    public Page<UserAddress> findAddrByPage(Page<UserAddress> page, Long userId) {
        page.addOrder(OrderItem.desc("last_update_time"));
        return page(page,new LambdaQueryWrapper<UserAddress>().eq(userId!=null,UserAddress::getUserId,userId));
    }
}
